/*
 * @Author: your name
 * @Date: 2021-04-09 14:56:11
 * @LastEditTime: 2021-04-09 15:15:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \web\node\middle_wares\log_pass.js
 */
export default (req,res,next)=>{
    //过滤前端请求
    if(req.path.toLowerCase().indexOf("/back") === -1){
        return next();
    }
    
    //判断登录是否合法
    if(req.session.token){
        return next()
    }

    //登录不合法
    //如果访问api接口
    if(req.path.toLowerCase().indexOf("/api") !== -1){
        return next(new Error("非法访问！"))
    }
    
    res.render("back/login.html")
}